﻿using System.ComponentModel;

namespace TK.Socket
{
    /// <summary>
    /// 数据包
    /// </summary>
    public class DataPacket
    {
        /// <summary>
        /// 数据类型
        /// </summary>
        public DataType DataType { get; set; }

        /// <summary>
        /// 连接ID,socket链接可能已断开，此ID不存在
        /// </summary>
        public int SessionId { get; set; }

        /// <summary>
        /// socket server ex tcp://127.0.0.1:6500
        /// </summary>
        public string Server { get; set; }

        /// <summary>
        /// socket client ex tcp://127.0.0.1:6500
        /// </summary>
        public string Client { get; set; }

        /// <summary>
        /// one compete data frame
        /// </summary>
        public byte[] Data { get; set; }

        /// <summary>
        /// 其他消息
        /// </summary>
        public string Message { get; set; }

        /// <summary>
        /// 发送
        /// </summary>
        public ISend SessionSend { get; set; }
    }

    public enum DataType
    {
        /// <summary>
        /// 连接
        /// </summary>
        [Description("连接")]
        Connect = 1,

        /// <summary>
        /// 断开
        /// </summary>
        [Description("断开")]
        DisConnect = 2,

        /// <summary>
        /// 数据接收
        /// </summary>
        [Description("数据接收")]
        Receive = 3,

        /// <summary>
        /// 异常
        /// </summary>
        [Description("异常")]
        Error = 4
    }
}